package com.cjh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthorityController {

    @PostMapping("/welcome")
    public String welcome(){
        return "欢迎进入主页";
    }

    @GetMapping("/fail")
    public String fail(){
        return "fail...";
    }

    @GetMapping("/add")
    @PreAuthorize("hasAuthority('sys:add')")
    public String add(){
        return "add";
    }

    @GetMapping("/delete")
    @PreAuthorize("hasAuthority('sys:delete')")
    public String delete(){
        return "delete";
    }

    @GetMapping("/update")
    @PreAuthorize("hasAuthority('sys:update')")
    public String update(){
        return "update";
    }

    @GetMapping("/select")
    @PreAuthorize("hasAuthority('sys:select')")
    public String select(){
        return "select";
    }

    @GetMapping("/role")
    public String role(){
        return "role";
    }
}
